<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>ACCOUNT AMMINISTRATIVO</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Calibri, Cambria}
.style3 {font-family: Verdana, Calibri, Cambria; font-size: small; }
.style4 {
	font-family: Verdana, Calibri, Cambria;
	font-weight: bold;
	font-style: italic;
	color: #FFFFFF;
}
body {
	background-color: #CCCCCC;
}
-->
</style>
</head>
<%@page import="utility.connections"%>
<%! String user,type,matr,cogn,pwd,nome,cognome,email,matricola,tipologia; %>
<%  
		
			if (session.getAttribute("user")==null)
			response.sendRedirect("loginerr.jsp");
			
			else
			{
	
			user = session.getAttribute("user").toString().toLowerCase();
			type = session.getAttribute("type").toString();
			matr = session.getAttribute("matricola").toString();
			nome = session.getAttribute("nome").toString();
			cogn = session.getAttribute("cognome").toString();
			}
%>
<body>
<table width="700" height="422" border="0" align="center">
  <tr>
    <td align="center" valign="middle"><img src="images/title.png" width="700" height="100"></td>
  </tr>
  <tr>
    <td height="257" align="center" valign="top"><table width="100%" border="0">
      <tr>
        <td align="center"><div align="left">
          <p class="style3">
<%
	try {
		Statement st = connections.getStatement();
		
		String qry = "select a.matricola as matricola, a.username as username, a.password as password, a.email as email, a.tipologia as tipologia,"
		           + "p.nome as nome, p.cognome as cognome from account a, personale p where a.username = '" + user
				   + "' and a.matricola=p.matricola";
		ResultSet rs = st.executeQuery(qry);
		if (rs.next())
		{
			user=rs.getString("username");
			pwd=rs.getString("password");
			nome=rs.getString("nome");
			cognome=rs.getString("cognome");
			matricola=rs.getString("matricola");
			email=rs.getString("email");
			switch(rs.getInt("tipologia"))
					{
				case 1: tipologia = "Amministratore";break;
				case 2: tipologia = "Addetto Amministrativo";break;
				case 3: tipologia = "Dipendente";break;
					}
		}
		else
		{
			session=request.getSession(true);
			session.invalidate();
			
			response.sendRedirect("loginerr.jsp");
		}
		
		rs.close();
		
	} catch (SQLException e) {
		e.printStackTrace();
	}	
%>
		
		  </p>
        </div></td>
        </tr>
      <tr>
        <td class="style1"><p align="center"><strong>Seleziona una delle seguenti opzioni </strong></p></td>
        </tr>
      <tr>
        <td class="style1"><div align="center">
          <table width="100%" border="0">
            <tr>
              <td width="16%">&nbsp;</td>
              <td width="27%"><div align="right">user:</div></td>
              <td width="32%"><input type="text" name="txtuser" size="60" value=<%=user%> readonly="readonly"></input></td>
              <td width="25%">&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right">password:</div></td>
              <td><input type="text" name="txtuser" size="60" value=<%=pwd%> readonly="readonly"></input></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right">tipologia:</div></td>
              <td><input type="text" name="txtuser" size="60" value=<%=tipologia%> readonly="readonly"></input></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right">email:</div></td>
              <td><input type="text" name="txtuser" size="60" value=<%=email%> readonly="readonly"></input></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right">matricola:</div></td>
              <td><input type="text" name="txtuser" size="60" value=<%=matricola%> readonly="readonly"></input></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right"></div></td>
              <td>
              
              <form action="modifica_pwd" method="post">
				<input type="submit" name="btnlogin" value="MODIFICA" onclick="location.href='dummy.jsp'"></input>
			  </form>
              
              </td>
              <td>
			  
			  <form action="Logout" method="post">
				<input type="submit" name="btnlogout" value="LOGOUT" onclick="location.href='dummy.jsp'"></input>
			  </form>
			  
			  </td>
            </tr>
          </table>
</div></td>
        </tr>
      <tr>
        <td class="style1">&nbsp;</td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="middle" bgcolor="#000099"><div align="right" class="style4">ACCOUNT ADDETTO AMMINISTRATIVO </div></td>
  </tr>
</table>
</body>
</html>
